/**
 * 
 */
package research.sbookmarking;

import java.util.*;

/**
 * This class is a wrapper for the data mined from Connotea.org. 
 * <P>
 * @author <A HREF="mailto:aatleung@gmail.com">Albert Leung</a>
 * @version 1.0
 */

public abstract class DataContainer {

	// contains the type of query performed
	private String queryName = null;
	
	// HashMap tags used in the data mined from Connotea.org
	private HashMap tags = null;

	// HashMap tags for each user in the data mined from Connotea.org
	private HashMap userTags = null;

	// contains the frequency of bookmarks in the data mined 
	private HashMap freqBookmarks = null;
	
	// contains the frequency of tags used in the data mined 
	private HashMap freqTags = null;
	
	//number of times a user posted
	private HashMap userFreq = null;
	
	//the list of users for each URL
	private HashMap urlUser = null;
	
	
	
	// contains the list of data from query of Connotea.org
	private List queryResults = null;
	
	/* contains a list of frequency of bookmarks and tags used in the data mined 
	 * from Connotea.org
	 * [0] - bookmarks
	 * [1] - tags
	private List repeats = null;
	 */

	/**
	 * Create a new DataContainer instance using the supplied list of
	 * Bookmarks/Posts.
	 * <p>
	 * @param queryResult the list of unique bookmarks/posts gather from the data mining 
	 * 				 of Connotea.
	 */
	public DataContainer (String className, List queryResults) {
		setClassName (className);
		setQueryResults (queryResults);
		
	}
	
	
	/**
	 * Saves the list of bookmarks, posts, or tags that was mined from Connotea.org.
	 * <P>
	 * @param className the type of query perfomed on Connotea.org.
	 * @param queryResult the list of unique bookmarks/posts gather from the data mining 
	 * 					  of Connotea.
	 */
	protected final void setQueryResults (List queryResult){
		queryResults=queryResult;
	}
	
	/**
	 * Returns the list of unique bookmarks/posts that was mined from Connotea.org.
	 * <p>
	 * @return a list of unique bookmarks/posts. 
	 */
	public List getQueryResults() {
		return queryResults;
	}

	/**
	 * Stores the list of tags used in the bookmarks that was mined 
	 * from Connotea.org.
	 * <p>
	 * @param tempTags {@HashMap HashMap} of unique tags gather from the data mining of 
	 * 				   Connotea.org.
	 */
	public void setTags (HashMap tagsFreq) {
		tags = tagsFreq;
	}
	
	/**
	 * Returns the list of unique tags used in the bookmarks that was mined 
	 * from Connotea.org.
	 * <p>
	 * @return list of tags used in the bookmarks.
	 */
	public HashMap getTags () {
		return tags;
	}

	/**
	 * Stores the distribution of the bookmarks in a HastMap. 
	 * <p>
	 * @param freqBook distribution of the bookmarks the data mined.
	 */
	public void setFreqBookmarks(HashMap bookmarkFreq){
		freqBookmarks = bookmarkFreq;
	}

	/**
	 * Returns the distribution of the bookmarks mined.
	 * <p>
	 * @return a HashMap of the frequency each bookmark mined.
	 */
	public HashMap getFreqBookmarks(){
		return freqBookmarks;
	}
	
	/**
	 * Stores the distribution of the tags in a HastMap. 
	 * <p>
	 * @param tagsFreq distribution of tags in the data mined.
	 */
	public void setFreqTags(HashMap tagsFreq){
		freqTags = tagsFreq;
	}

	/**
	 * Returns the distribution of the tags mined.
	 * <p>
	 * @return a {@link HashMap HashMap} of the frequency.
	 */
	public HashMap getFreqTags(){
		return freqTags;
	}

	/**
	 * Returns a string representation of the object. The 
	 * toString method returns a string that "textually 
	 * represents" this object.
	 * <p>
	 * @return a string representation of the object.
	 */
	public String toString() {
		Iterator items = getQueryResults().iterator();
		StringBuffer buffer = new StringBuffer();
		
		while (items.hasNext()) {
			buffer.append(items.next().toString());
		}
		
		return buffer.toString();
	}


	public String getQueryName() {
		return queryName;
	}


	private void setClassName(String queryName) {
		this.queryName = queryName;
	}


	/**
	 * Returns a {@HashMap HashMap) containing the number of times a user posted
	 * in the data collected.
	 * <p>
	 * @return a {@HashMap HashMap} containing the number of times a user posted 
	 */
	public HashMap getUserFreq() {
		return userFreq;
	}


	/**
	 * Saves the data that contains the list of users for each URL
	 * in the data collected.
	 * <p>
	 * @param userFreq list of users for each URL
	 */
	public void setUserFreq(HashMap userFreq) {
		this.userFreq = userFreq;
	}


	/**
	 * Returns a {@HashMap HashMap) containing the list of users for each URL
	 * in the data collected.
	 * <p>
	 * @return a {@HashMap HashMap} containing the number of times a user posted 
	 */
	public HashMap getUrlUser() {
		return urlUser;
	}

	//number of times a user posted
	
	//the list of users for each URL
	
	/**
	 * Saves the data that contains the number of times a user posted
	 * in the data collected.
	 * <p>
	 * @param urlUser the list of users for each URL
	 */
	public void setUrlUser(HashMap urlUser) {
		this.urlUser = urlUser;
	}


	public HashMap getUserTags() {
		return userTags;
	}


	public void setUserTags(HashMap userTags) {
		this.userTags = userTags;
	}
}
